import service from '@/request/index'

//获取授权
export const getPermissions = data => {
  return service({
    method: 'post',
    url: '/api/permissions/tree',
    data
  })
};
export const getAuth = () => {
  return service({
    method: 'get',
    url: '/api/abp/application-configuration'
  })
};
/**
 * 【设备】相关接口
 * */
//查询设备列表
export const getDeviceListApi = params => {
  return service({
    method: 'get',
    url: '/api/device/all',
    params
  })
};
//创建设备
export const createDevice = data => {
  return service({
    method: 'post',
    url: '/api/device/create',
    data,
    headers: {
      'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq'
    }
  })
};
//删除设备
export const deleteDevice = params => {
  return service({
    method: 'delete',
    url: '/api/device/delete',
    params
  })
};
//获取设备
export const getDevice = params => {
  return service({
    method: 'get',
    url: '/api/device/get',
    params
  })
};
//【设备管理】 下拉框列表获取
export const getDeviceOptions = params => {
  return service({
    method: 'get',
    url: '/api/device/options',
    params
  })
};
//修改设备
export const deviceUpdate = data => {
  return service({
    method: 'put',
    url: '/api/device/update',
    data
  })
};
//切换当前设备ip
export const deviceIpUpdate = data => {
  return service({
    method: 'put',
    url: '/api/device/setip',
    data
  })
};
//修改设备限时
export const deviceTimeoutUpdate = data => {
  return service({
    method: 'put',
    url: '/api/device/timeout/update',
    data
  })
};
//绑定测试仪
export const deviceTesterBind = data => {
  return service({
    method: 'put',
    url: '/api/device/tester/bind',
    data
  })
};
//绑定拧紧枪
export const deviceTightenGunBind = data => {
  return service({
    method: 'put',
    url: '/api/device/tightengun/bind',
    data
  })
};
/**
 * 【物料】相关接口
 * */
export const getMaterialListApi = params => {
  return service({
    method: 'get',
    url: '/api/material/all',
    params
  })
};
export const createMaterial = data => {
  return service({
    method: 'post',
    url: '/api/material/create',
    data
  })
};
export const deleteMaterial = params => {
  return service({
    method: 'delete',
    url: '/api/material/delete',
    params
  })
};
export const getMaterial = params => {
  return service({
    method: 'get',
    url: '/api/material/get',
    params
  })
};
export const getMaterialBarcode = params => {
  return service({
    method: 'get',
    url: '/api/material/get/barcode',
    params
  })
};
export const getMaterialOptions = params => {
  return service({
    method: 'get',
    url: '/api/material/options',
    params
  })
};
export const materialUpdate = data => {
  return service({
    method: 'put',
    url: '/api/material/update',
    data
  })
};
/**
 * 【工站管理】相关接口
 * */
export const workStationUpdate = data => {
  return service({
    method: 'put',
    url: '/api/workstation/update',
    data
  })
};
export const getWorkStationListApi = params => {
  return service({
    method: 'get',
    url: '/api/workstation/all',
    params
  })
};
export const getWorkStation = params => {
  return service({
    method: 'get',
    url: '/api/workstation/get',
    params
  })
};
export const getWorkStationOptions = params => {
  return service({
    method: 'get',
    url: '/api/workstation/options',
    params
  })
};
/**
 * 【配方管理】相关接口
 * */

export const getRecipeListApi = params => {
  return service({
    method: 'get',
    url: '/api/recipe/all',
    params
  })
};
export const createRecipe = data => {
  return service({
    method: 'post',
    url: '/api/recipe/create',
    data
  })
};
export const deleteRecipe = params => {
  return service({
    method: 'delete',
    url: '/api/recipe/delete',
    params
  })
};
export const getRecipe = params => {
  return service({
    method: 'get',
    url: '/api/recipe/get',
    params
  })
};
export const getRecipeOptions = params => {
  return service({
    method: 'get',
    url: '/api/recipe/options',
    params
  })
};
export const recipeUpdate = data => {
  return service({
    method: 'put',
    url: '/api/recipe/update',
    data
  })
};
/**
 * 【产品管理】相关接口
 * */
export const getProductListApi = params => {
  return service({
    method: 'get',
    url: '/api/product/all',
    params
  })
};
export const createProduct = data => {
  return service({
    method: 'post',
    url: '/api/product/create',
    data
  })
};
export const deleteProduct = params => {
  return service({
    method: 'delete',
    url: '/api/product/delete',
    params
  })
};
export const getProduct = params => {
  return service({
    method: 'get',
    url: '/api/product/get',
    params
  })
};
export const getProductOptions = params => {
  return service({
    method: 'get',
    url: '/api/product/options',
    params
  })
};
export const productUpdate = data => {
  return service({
    method: 'put',
    url: '/api/product/update',
    data
  })
};
export const selectRecipe = data => {
  return service({
    method: 'post',
    url: '/api/product/select/recipe',
    data
  })
};

/**
 * 【数据管理】相关接口
 * */
export const postExportListApi = data =>{
  return service({
    method: 'post',
    url: '/api/productorder/title/export/detail',
    data,
    responseType: 'blob'
  })
};
export const getExportListApi = params =>{
  return service({
    method: 'get',
    url: '/api/productorder/all/station/detail',
    params
  })
};
export const getProductOrderPageList = data => {
  return service({
    method: 'post',
    url: '/api/productorder/title/page',
    data
  })
};

export const exportProductOrderList = data => {
  return service({
    method: 'post',
    url: '/api/productorder/title/export',
    responseType: "arraybuffer",
    data
  })
};

export const deleteProductOrder = params => {
  return service({
    method: 'delete',
    url: '/api/productorder/title/delete',
    params
  })
};

export const hangupProductOrder = data => {
  return service({
    method: 'post',
    url: '/api/productorder/title/hangup',
    data
  })
};

export const getPrductOrderTitle = params => {
  return service({
    method: 'get',
    url: '/api/productorder/title/get',
    params
  })
};

export const getSubTableContentApi = params =>{
  return service({
    method:'get',
    url:'/api/testingresult/entry/productorder/all',
    params
  })
};

/**
 * 【用户管理】相关接口
 * */
export const getUserPageList = data => {
  return service({
    method: 'post',
    url: '/api/users/page',
    data
  })
};

export const createUser = data => {
  return service({
    method: 'post',
    url: '/api/users/create',
    data
  })
};

export const updateUser = data => {
  return service({
    method: 'post',
    url: '/api/users/update',
    data
  })
};

export const deleteUser = data => {
  return service({
    method: 'post',
    url: '/api/users/delete',
    data
  })
};

export const getUserDevice = userId => {
  return service({
    method: 'post',
    url: '/api/users/GetUserDeviceIds?userId=' + userId
  })
};

export const GetUserListByDevice = data => {
  return service({
    method: 'post',
    url: '/api/users/GetUserListByDevice',
    data
  })
};

/**
 * 【条码比对】相关接口
 * */
export const createCompare = data => {
  return service({
    method: 'post',
    url: '/api/barcodecompare/create',
    data
  })
};

export const updateCompare = data => {
  return service({
    method: 'put',
    url: '/api/barcodecompare/update',
    data
  })
};

export const getCompare = params => {
  return service({
    method: 'get',
    url: '/api/barcodecompare/get',
    params
  })
};
/**
 * 【螺丝管理】相关接口
 * */
export const createScrew = data => {
  return service({
    method: 'post',
    url: '/api/screw/create',
    data
  })
};

export const updateScrew = data => {
  return service({
    method: 'put',
    url: '/api/screw/update',
    data
  })
};

export const deleteScrew = data => {
  return service({
    method: 'delete',
    url: '/api/screw/delete',
    data
  })
};

export const getScrewList = params => {
  return service({
    method: 'get',
    url: '/api/screw/all',
    params
  })
};

/**
 * 【NG管理】相关接口
 * */
export const getNg = () => {
  const data = {
    "pageIndex": 1,
    "pageSize": 10,
    "filter": "NG"
  };
  return service({
    method: 'post',
    url: '/api/datadictionary/page',
    data
  })
};

export const getNgDetail = data => {
  return service({
    method: 'post',
    url: '/api/datadictionary/pageDetail',
    data
  })
};

export const createNgDetail = data => {
  return service({
    method: 'post',
    url: '/api/datadictionary/createDetail',
    data
  })
};

export const updateNgDetail = data => {
  return service({
    method: 'post',
    url: '/api/datadictionary/updateDetail',
    data
  })
};

export const deleteNgDetail = data => {
  return service({
    method: 'post',
    url: '/api/datadictionary/delete',
    data
  })
};
/**
 * 包装相关接口
 * */
export const getPackage = params =>{
  return service({
    method: 'get',
    url: 'api/workstation26/get',
  })
};
export const packageSet = data =>{
  return service({
    method: 'post',
    url: 'api/workstation26/packagenum/set',
    data
  })
};
